package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.person.bean.PersonBean;
import com.xinfu.newproject.bean.person.body.PersonBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.person.PersonModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class PersonPresenter {
    private IView.IUpPersonView mIUpPersonView;

    private PersonModel mPersonModel;

    public PersonPresenter(IView.IUpPersonView iUpPersonView) {
        this.mIUpPersonView = iUpPersonView;
        mPersonModel = new PersonModel();
    }

    /**
     * 获取首页内容
     */
    public void upDatePerson() {

        PersonBody personBody = new PersonBody(mIUpPersonView.header(), mIUpPersonView.userId(), mIUpPersonView.realname(), mIUpPersonView.avatar(), mIUpPersonView.sex(), mIUpPersonView.phone(), mIUpPersonView.projectId(), mIUpPersonView.tenantId());

        mPersonModel.upPerson(personBody, new MyCallBack<PersonBean>() {
            @Override
            public void onSuccess(PersonBean personBean) {

                if (personBean.isSuccess()) {
                    mIUpPersonView.getData(personBean);
                } else {
                    mIUpPersonView.showToast(personBean.getMessage());
                }
//                mISubmitRepairView.showToast(addRepairBean.getMessage());
            }

            @Override
            public void onError(String header, String message) {

                mIUpPersonView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIUpPersonView.closeDispose(disposable);
            }
        });


    }


}
